package com.webserver.core;

import java.io.InputStream;
import java.net.Socket;

/**
 * @author liyang
 * @version 1.0
 * @package com.webserver.core
 * @file ClientHandler.java
 * @description
 * @time 2024-04-30 15:14
 */

/*线程不再需要共享数据，也就不再需要定义为内部类了
* 这是一个线程任务➡实现接口*/
public class ClientHandler implements Runnable{
    private Socket socket;
    public ClientHandler(Socket socket){
        this.socket = socket;

    }
    @Override
    public void run() {
        try {
            InputStream in = socket.getInputStream() ;
            int d;
            while ((d = in.read())!=-1){
                System.out.print((char) d);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
